home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Genie / Projects / V3DDemo / Source / Sources / V3DAgentDoc.cc next >
Encoding:
C/C++ Source or Header  |  2000-06-24  |  1.7 KB  |  83 lines

  1. /*    ==============
  2.  *    V3DAgentDoc.hh
  3.  *    ==============
  4.  *
  5.  *    Implemented by V3DAgentDoc.cc
  6.  */
  7.  
  8. #include <Menus.h>
  9.  
  10. #include "PedWindow.hh"
  11. #include "PedFSRef.hh"
  12. #include "V3DDocModel.hh"
  13. #include "V3DAgentDoc.hh"
  14. #include "V3DPanePort.hh"
  15.  
  16. V3DAgentDoc::V3DAgentDoc(PedTask *inParent, V3DDocModel *inDocument)
  17. : PedAgentDoc(inParent), mDocument(inDocument)
  18. {
  19.     inDocument->retain();
  20. }
  21.  
  22. V3DAgentDoc::~V3DAgentDoc()
  23. {
  24.     if (mDocument) {
  25.         mDocument->release();
  26.     }
  27. }
  28.  
  29. PedDocument *
  30. V3DAgentDoc::Document()
  31. {
  32.     return mDocument;
  33. }
  34.  
  35. void
  36. V3DAgentDoc::InitWindow()
  37. {
  38.     if (!mWindow && mDocument) {
  39.         mWindow = new PedWindow(this);
  40.         mDocument->Load();
  41.         
  42.         Rect rect = {18, 0, 18+2*4+11*25+16, 2*4+6*80+16};
  43.         short mbarHeight = ::GetMBarHeight();
  44.         short vMargin = (qd.screenBits.bounds.bottom - rect.bottom) - mbarHeight;
  45.         short hMargin = (qd.screenBits.bounds.right - rect.right);
  46.         ::OffsetRect(&rect, hMargin / 2, mbarHeight + vMargin / 3);
  47.         
  48.         // Set the bounds before creating the pane, because things aren't
  49.         // perfect yet and the pane will be sized to the old bounds.
  50.         mWindow->SetBounds(rect);
  51.         if (mDocument->File()) {
  52.             mWindow->SetTitle(mDocument->File()->FSS().name);
  53.         }
  54.         
  55.         C3DModel *model = mDocument->Model();
  56.         if (model) {
  57.             V3DPanePort *pane = new V3DPanePort(*mWindow, *model);
  58.             mWindow->SetPane(pane);
  59.         }
  60.         
  61.         //mAnimateChore = new PedChoreGeneric(&Animate3DFunc, this);
  62.         //mAnimateChore->retain();
  63.         //Ped1AppProcess::Me().MainModule().InstallIdleChore(mAnimateChore);
  64.     }
  65. }
  66.  
  67. void
  68. V3DAgentDoc::ProcessKey(EventRecord &inEvent)
  69. {
  70.     char c = inEvent.message & charCodeMask;
  71.     short code = (inEvent.message & keyCodeMask) >> 8;
  72.     ProcessKey(c, code);
  73. }
  74.  
  75. void
  76. V3DAgentDoc::ProcessKey(char inChar, short inCode)
  77. {
  78.     char c = inChar;
  79.     
  80.     mWindow->Pane()->DoKey(c);
  81. }
  82.  
  83.